﻿#region

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using NetBay.Core.BusinessEntities.Workflow;
using Rio.Framework.Localisation;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;

#endregion

namespace Rio.Framework.Pages.Workflow
{
    public class WorkflowCommentColumn : GridViewDataColumn
    {
        #region Instance Methods

        public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
        {
            WorkflowHisto histo = (WorkflowHisto) dataItem;

            if (histo != null && histo.Comment != null && histo.Comment.StartsWith("http://") || histo.Comment.StartsWith("https://"))
            {
                return new HyperlinkButton
                           {
                               Content = Resx.GetLabel(ResxCommon.LINK),
                               NavigateUri = new Uri(histo.Comment, UriKind.Absolute),
                               Foreground = new SolidColorBrush(Colors.Blue),
                               TargetName = "_blank"
                           };
            }
            else
            {
                return base.CreateCellElement(cell, dataItem);
            }
        }

        #endregion
    }
}